Skip to main content

VirtualDisplay

A Virtual display instance used for virtually rendering display functions.

Functions​

drawPixel​

Virtualdisplay.drawPixel( x, y, color )

Draws a pixel at the given coordinates.

Arguments:

  • x [ number ] The x coordinate of the pixel.
  • y [ number ] The y coordinate of the pixel.
  • color [ Color | string | ColorInteger ] The color of the pixel.

drawLine​

Virtualdisplay.drawLine( x, y, x1, y1, color )

Draws a line between the given coordinates.

Arguments:

  • x [ number ] The x coordinate of the start of the line.
  • y [ number ] The y coordinate of the start of the line.
  • x1 [ number ] The x coordinate of the end of the line.
  • y1 [ number ] The y coordinate of the end of the line.
  • color [ Color | string | ColorInteger ] The color of the line.

drawFilledCircle​

Virtualdisplay.drawFilledCircle( x, y, radius, color )

Draws a filled circle around the given coordiantes.

Arguments:

  • x [ number ] The x coordinate of the centre of the circle.
  • y [ number ] The y coordinate of the centre of the circle.
  • radius [ number ] The radius of the circle.
  • color [ Color | string | ColorInteger ] The color of the circle.

drawCircle​

Virtualdisplay.drawCircle( x, y, radius, color )

Draws a circle around the given coordiantes.

Arguments:

  • x [ number ] The x coordinate of the centre of the circle.
  • y [ number ] The y coordinate of the centre of the circle.
  • radius [ number ] The radius of the circle.
  • color [ Color | string | ColorInteger ] The color of the circle.

drawFilledTriangle​

Virtualdisplay.drawFilledTriangle( x1, y1, x2, y2, x3, y3, color )

Draws a filled triangle between the given coordinates.

Arguments:

  • x1 [ number ] The x coordinate of point 1 of the triangle.
  • y1 [ number ] The y coordinate of point 1 of the triangle.
  • x2 [ number ] The x coordinate of point 2 of the triangle.
  • y2 [ number ] The y coordinate of point 2 of the triangle.
  • x3 [ number ] The x coordinate of point 3 of the triangle.
  • y3 [ number ] The y coordinate of point 3 of the triangle.
  • color [ Color | string | ColorInteger ] The color of the triangle.

drawTriangle​

Virtualdisplay.drawTriangle( x1, y1, x2, y2, x3, y3, color )

Draws a triangle between the given coordinates.

Arguments:

  • x1 [ number ] The x coordinate of point 1 of the triangle.
  • y1 [ number ] The y coordinate of point 1 of the triangle.
  • x2 [ number ] The x coordinate of point 2 of the triangle.
  • y2 [ number ] The y coordinate of point 2 of the triangle.
  • x3 [ number ] The x coordinate of point 3 of the triangle.
  • y3 [ number ] The y coordinate of point 3 of the triangle.
  • color [ Color | string | ColorInteger ] The color of the triangle.

drawFilledRect​

Virtualdisplay.drawFilledRect( x, y, rWidth, rHeight, color )

Draws a filled rectangle at the given coordinates.

Arguments:

  • x [ number ] The x coordinate of the top left corner of the rectangle.
  • y [ number ] The y coordinate of the top left corner of the rectangle.
  • rWidth [ number ] The width of the rectangle.
  • rHeight [ number ] The height of the rectangle.
  • color [ Color | string | ColorInteger ] The color of the rectangle.

drawRect​

Virtualdisplay.drawRect( x, y, rWidth, rHeight, color )

Draws a rectangle at the given coordinates.

Arguments:

  • x [ number ] The x coordinate of the top left corner of the rectangle.
  • y [ number ] The y coordinate of the top left corner of the rectangle.
  • rWidth [ number ] The width of the rectangle.
  • rHeight [ number ] The height of the rectangle.
  • color [ Color | string | ColorInteger ] The color of the rectangle.

drawWithPoints​

Virtualdisplay.drawWithPoints( points, color )

Draws a custom poly from an array of points.

Arguments:


drawText​

Virtualdisplay.drawText( x, y, text, color, font, maxWidth, wordWrappingEnabled )

Draws text.

Arguments:

  • x [ number ] The x-coordinate of the text.
  • y [ number ] The y-coordinate of the text.
  • text [ string ] The text to draw.
  • color [ Color | string | ColorInteger ] The color of the text.
  • fontName [ string? ] The font to use. (defaults to whatever the default font the font manager is using).
  • maxWidth [ integer? ] The max width before the text wraps around.
  • wordWrappingEnabled [ boolean? ] Whether the text does word wrapping or not.

drawFromTable​

Virtualdisplay.drawFromTable( tbl )

Draws to the virtual display via a table instead of individual funciton calls.

Arguments:

  • tbl [ PixelTable ] The pixel table of things to draw.

loadImage​

Virtualdisplay.loadImage( width, height, path, customSearch )

Draws a image to the virtual display. Images are loaded from the DisplayImages folder in the mods directory, you can generate your own images with the use of our PNG to pixel data python converter in the mod.

Arguments:

  • width [ integer ] The width of the image.
  • height [ integer ] The height of the image.
  • path [ string ] The path of the image. Put example.json here to load a example image (256x256 image).
  • customSearch [ boolean ] If the path searching is custom or not.
Note:

When customSearch is enabled, the path is now a standard file path and doesnt have the ScrapComputers DisplayImages folder path prefix. This means you will have to provide a full file path such as "$CONTENT_<contentid>/".


render​

Virtualdisplay.render( xOffset, yOffset, cacheBased )

Renders the contents of the virtual display to a PixelTable.

Arguments:

  • xOffset [ integer? ] The x offset of the contents of the virtual display.
  • yOffset [ integer? ] The y offset of the contents of the virtual display.
  • cacheBased [ boolean? ] Whether the virtual display caches its output buffer or not (This means it will not draw the same things that were drawn last render call).

Returns:


clear​

Virtualdisplay.clear( color )

Clears the virtual display.

Arguments:


setDimensions​

Virtualdisplay.setDimensions( width, height )

Sets the virtual displays' dimensions.

Arguments:

  • width [ integer ] The new width.
  • height [ integer ] The new height.

getDimensions​

Virtualdisplay.getDimensions()

Gets the virtual displays' dimensions.

Returns:

  • [ integer ] The width.
  • [ integer ] The height.

calcTextSize​

Virtualdisplay.calcTextSize( text, font, maxWidth, wordWrappingEnabled, dynamicHeight )

Calculates the bounding box of a piece of text.

Arguments:

  • text [ string ] The text to check.
  • font [ string? ] The texts' font.
  • maxWidth [ integer? ] The max width before the text started to wrap.
  • dynamicHeight [ boolean? ] Whether the bounding box should be dynamic to the physical text or the max font height (only works if word wrapping is disabled).

Returns:

  • [ integer ] The width.
  • [ integer ] The height.

drawASCFText​

Virtualdisplay.drawASCFText( xOffset, yOffset, text, fontName, color, rotation, fontSize, colorToggled )

Draws ASCF text to a virtual display.

Arguments:

  • xOffset [ number ] The x-coordinate.
  • yOffset [ number ] The y-coordinate.
  • text [ string ] The text to draw.
  • fontName [ string ] The name of the font.
  • color [ string|Color ] The color of the text to set.
  • rotation [ number? ] The rotation.
  • fontSize [ number ] The size of the font to use.
  • colorToggled [ boolean? ] If it should support colors or not in text.

calcASCFTextSize​

Virtualdisplay.calcASCFTextSize( fontName, text, fontSize, rotation, maxWidth, coloredMode )

Calculates text size, No error handling provided.

Arguments:

  • fontName [ string ] The name of the font.
  • text [ string ] The text.
  • fontSize [ number ] The size of the font.
  • rotation [ number? ] The rotation.
  • maxWidth [ integer? ] The max width before the text wraps around.
  • coloredMode [ boolean? ] Whether the text has hex color formatting or not.

Returns: -- [ integer ] The width. -- [ integer ] The height.


setOptimizationThreshold​

Virtualdisplay.setOptimizationThreshold( num )

This function sets the optimization threshold of the virtual display. This is a number randing from 0 - 1 that dictates how similar a colour has to be to its previous cached pixel for it to be rendered, this means that this only affects the render if its a cache based render.

Arguments:

  • num [ number ] The optimization threshold to set.

getOptimizationThreshold​

Virtualdisplay.getOptimizationThreshold()

Returns the virtual displays optimization threshold.

Returns:

  • [ number ] The virtual displays optimization threshold.

clearCache​

Virtualdisplay.clearCache()

Manually clears the cache buffer of the virtual display, this is so you can do a force a redraw of all parts of the virtual display even with a cache based render.